package indi.zhifa.recipe.bailan.framework.auth.entity.vo;
import indi.zhifa.recipe.bailan.framework.auth.entity.po.BaseAuthNodeEntity;
import indi.zhifa.recipe.bailan.framework.auth.entity.po.BaseDomainEntity;
import indi.zhifa.recipe.bailan.framework.common.entity.exception.ServiceException;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class BaseDomainVo extends BaseDomainEntity{

    Map<String, BaseAuthNodeEntity> departmentEntityMap;

    public BaseDomainVo(){
        departmentEntityMap = new HashMap<>();
    }

    public BaseAuthNodeEntity checkDepartment(String pDepCode){
        BaseAuthNodeEntity baseAuthNodeEntity = departmentEntityMap.get(pDepCode);
        if(null == baseAuthNodeEntity){
            throw new ServiceException("BaseDomainVo 中不存在code为"+pDepCode+"的部门");
        }
        return baseAuthNodeEntity;
    }

}
